<?
if (!defined ('L_MOD')) {die("<h3>You can`t access this file...</h3>");}

print "<h2>"._MYSITES_."</h2><br>";
if (!isset($criteria) || $criteria==1)
{
	$select1='selected';
	$select2='';
	$select3='';
	$query_crit_add='';
}elseif($criteria==2)
{
	$select1='';
	$select2='selected';
	$select3='';
	$query_crit_add="and mod_wcps='1'";
}elseif($criteria==3)
{
	$select1='';
	$select2='';
	$select3='selected';
	$query_crit_add="and mod_wcps='0'";
}

print '<form name="form" action="index.php?nma='.$nma.'&fla='.$fla.'" method="post">
	<table align="right" border="0">
		<tr>
			<td>
				<select name="criteria">
					<option value="1" '.$select1.'>'._VSE_.'</option>
					<option value="2" '.$select2.'>'._ONLYWCPS_.'</option>
					<option value="3" '.$select3.'>'._ONLYNOWCPS_.'</option>
				</select>&nbsp;<input type="submit" value="'._SHOW_.'">
			</td>
		</tr>
	</table>
</form>';

$query=mysql_query("SELECT links . * , category.mod_id AS cat_id, 
	category.mod_category AS category_name, 
	category.mod_18 AS mod_18
	FROM ${wcpref}".$nma." links 
	INNER JOIN ${wcpref}".$nma."_category category ON links.mod_cat_id = category.mod_id 
	WHERE links.mod_user_id = '".$_SESSION['user_id']."' ".$query_crit_add."");

$d=0;
print '<table align="center" cellpadding="3" cellspacing="1" border="0" width="98%">';
while($result=mysql_fetch_array($query))
{
	$d++;$iclass = ($d % 2) ? "even" : "odd";
	extract($result);
	if ($mod_18==1)
		$add18='<font size="-3" color="#FF0000"><sup>18+</sup></font>';
	else
		$add18='';
	
	if ($mod_block==0)
		$lock_img='<img src="/images/'.$nma.'/lock_unlock.png" border="0" title="'._UNLOCKEDSITE_.'">';
	elseif($mod_block==1)
		$lock_img='<img src="/images/'.$nma.'/lock.png" border="0" title="'._LOCKEDSITE_.'">';
	
	if ($mod_map==1)
		$map_img='<img src="/images/'.$nma.'/chart_organisation.png" border="0" title="'._MAPALLOW_.'">';
	else
		$map_img='';
	
	if ($mod_wcps==1)
		$wcps_img='<a href="http://wcps.ru" target="_blank"><img src="/images/'.$nma.'/wcps.gif" border="0" title="'._WCPSSITE_.'"></a>';
	else
		$wcps_img='';
	
	if ($mod_ban==0)
		$ban_img='<img src="/images/'.$nma.'/accept.png" border="0" title="'._WCPSNOBAN_.'">';
	else
		$ban_img='<img src="/images/'.$nma.'/cross_octagon_fram.png" border="0" title="'._WCPSBAN_.'">';
	
	print '<tr class="'.$iclass.'">
		<td>
			<table align="center" cellspacing="1" cellpadding="1" border="0" width="100%">
				<tr>
					<td align="center"><a href="index.php?nma='.$nma.'&fla=category&cid='.$mod_cat_id.'">'.$category_name.'</a>'.$add18.'</td>
					<td><a href="http://'.$mod_url .'" target="_blank">'.$mod_name.'</a></td>
					<td>';
						if ($mod_wcps==0)
						{
							if ($mod_reverse_url!='')
								print'<a href="http://'.$mod_reverse_url.'" target="_blank" title="http://'.$mod_reverse_url.'">'._TYPERURL_.'</a>';
						}
					print'</td>
					<td align="center" width="19px">'.$wcps_img.'</td>
					<td align="center" width="19px">'.$lock_img.'</td>
					<td align="center" width="19px">'.$map_img.'</td>
					<td align="center" width="19px">'.$ban_img.'</td>
				</tr>';
				//888888888888888888888888888888888888888888888888888888
				if ($mod_wcps==1)
				{
					print '<tr>
						<td colspan="7">';
							$dat_add=CreateDate($mod_dat, "dmY");
							$rduN=CreateDate(date("d.m.Y"), "U");
							$font_end='</font>';
							if ($mod_allow_url=='0000-00-00')
							{
								$pay_u_title=_PAY_;
								$payed_url=_NO_;
								$font_beg_url='<font color="#FF0000">';
							}elseif($mod_allow_url!='')
							{
								$pay_u_title=_MORPAY_;
								$payed_url=CreateDate($mod_allow_url, "dmy");
								$rduU=CreateDate($mod_allow_url, "U");
								if ($rduU>=$rduN)
									$font_beg_url='<font color="#008000">';
								else
									$font_beg_url='<font color="#FF0000">';
							}
				
							if ($mod_allow_map=='0000-00-00')
							{
								//$pay_m_title=_PAY_;
								$payed_map=_NO_;
								$font_beg_map='<font color="#FF0000">';
							}elseif($mod_allow_map!='')
							{
								//$pay_m_title=_MORPAY_;
								$payed_map=CreateDate($mod_allow_map, "dmy");
								$rduM=CreateDate($mod_allow_map, "U");
								if ($rduM>=$rduN)
									$font_beg_map='<font color="#008000">';
								else
									$font_beg_map='<font color="#FF0000">';
							}
							print'<table align="center" width="100%">
								<tr>
									<td>'._ADDED_.'</td>
									<td>'.$dat_add.'</td>
									<td align="right">'._LINKSCHPAYED_.'</td>
									<td>'.$font_beg_url.$payed_url.$font_end.'</td>
									<td align="right">'._MAPSCHPAYED_.'</td>
									<td>'.$font_beg_map.$payed_map.$font_end.'</td>
								</tr>
								<tr>
									<td colspan="2">&nbsp;</td>
									<td colspan="4" align="center"><a href="index.php?nma=finance&fla=payment">'.$pay_u_title.'</a></td>';
									//<td colspan="2" align="center">'.$pay_m_title.'</td>
								print'</tr>
							</table>';
						print'</td>
					</tr>';
				}
				//88888888888888888888888888888888888888888888888888888
				print'<tr>
					<td colspan="7" align="center"><b>'._TYPESHORT_.'</b></td>
				</tr>
				<tr>
					<td colspan="7">'.$mod_short.'</td>
				</tr>';
				if ($mod_full!="")
				{
					print'<tr>
						<td colspan="7" align="center"><a href="#" onclick="choose(\'fulldesc'.$mod_id.'\')">'._TYPEFULL_.'</a></td>
					</tr>
					<tr>
						<td colspan="7">
							<div id="fulldesc'.$mod_id.'" style="display:none;">'.$mod_full.'
								<br><br>
							<a href="#" onclick="choose(\'fulldesc'.$mod_id.'\')">'._HIDEFULL_.'</a>
							</div>
						</td>
					</tr>';
				}
				
				print'<tr>';
					print'<td colspan="7" align="right">';
						if ($mod_wcps==0)
							print'<a href="index.php?nma='.$nma.'&fla=edsite&sid='.$mod_id.'"><img src="/images/'.$nma.'/text_signature.png" border="0" title="'._EDIT_.'"></a>';
						else
							print'<a href="index.php?nma='.$nma.'&fla=edwcpssite&sid='.$mod_id.'"><img src="/images/'.$nma.'/text_signature.png" border="0" title="'._EDIT_.'"></a>';
						print "<a href='index.php?nma=".$nma."&fla=dsite&sid=".$mod_id."' onClick=\"return confirm('"._DELETE_." &quot;".$mod_name."&quot;?');\">
							<img src='/images/".$nma."/cross.png' border='0' title='"._DELETE_."'>
						</a>";
					print '</td>
				</tr>';
			print'</table>
		</td>
	</tr>';
}
print'</table>';
print '<br><table>
	<tr>
		<td align="left">
			<a href="?nma='.$nma.'&fla=index">'._TOCATEGORY_.'</a>&nbsp;&nbsp;
		</td>
	</tr>
</table>';
print '<br><br><table align="center" border="0" cellpadding="1" cellspacing="1">
	<tr>';
		print'<td align="center">
			&nbsp;&nbsp;<a href="'.$wccat_service_url.'/index.php?nma=wccat&fla=addwcsite">'._ADDWCPSSITE_.'</a>&nbsp;&nbsp;
		</td>
		<td align="center">';
			if ($wccat_allowadd==1)
				print'&nbsp;&nbsp;<a href="?nma='.$nma.'&fla=addsite">'._ADDOTHERSITE_.'</a>';
		print'</td>
	</tr>
</table>';

function CreateDate($dat, $mode)
{
	if ($mode=="dmY")
		$NewDat=date('d.m.Y', strtotime($dat)); 
	elseif($mode=="U")
		$NewDat=date(strtotime($dat)); 
	elseif($mode=="dmy")
		$NewDat=date('d.m.y', strtotime($dat)); 
	return $NewDat;
}
?>


<script language="JavaScript">
	function choose(id)
    {
		if (document.getElementById(id).style.display == 'none')
			show(id);
		else if(document.getElementById(id).style.display == 'block')
			hide(id);
	}

	function hide(id)
	{
		document.getElementById(id).style.display = 'none';
	}

	function show(id)
	{
		document.getElementById(id).style.display = 'block';
	}

</script>